<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>异常料框</title>
</head>
<body>
<section>
    <div>
        <div class="layui-card">
            <div class="adp-content">
                <form id="queryForm"></form>
                <table id="queryTable"></table>
            </div>
        </div>
    </div>
</section>
<div style="width: 600px;display: none;" id="mergeFormDiv">
    <form action="" method="post" id="mergeForm" class="adp-center"></form>
</div>
</body>
</html>
<script src="../static/adp/import.js"></script>

<script type="text/html" id="OPERATION_ROW_TPL">
    <a class="layui-btn layui-btn-sm" lay-event="edit"> <i class="layui-icon layui-icon-edit"></i>处理</a>
</script>
<!--<script type="text/html" id="USER_ROLE_TPL">-->
<!--{{# layui.each(d.roles, function(index, item){ }}-->
<!--<span class="layui-badge layui-bg-blue">{{= item.roleName}}</span>-->
<!--{{# }); }}-->
<!--</script>-->

<script type="text/javascript">
    var queryform = $("#queryForm").adpForm({
        elem: [{type: "text", label: "料框编号", name: "containerId", placeholder: "请输入关键字"}/*,
            {type: "text", label: "发行人", name: "issuePerson", placeholder: "请输入关键字"},
            {type: "date", label: "发行日志从", name: "startDate", placeholder: "请输入关键字"},
            {type: "date", label: "至", name: "endDate", placeholder: "请输入关键字"},
            {type: "select", label: "料框状态", name: "status", placeholder: "请选择状态",
                data:[{key:"0",value:"所有"},{key:"初始空闲",value:"初始空闲"},{key:"空框待用",value:"空框待用"},{key:"待入库",value:"待入库"},
                    {key:"在库",value:"在库"},{key:"待返工",value:"待返工"},{key:"待出库",value:"待出库"},{key:"待退料",value:"待退料"},{key:"已出库",value:"已出库"}]}*/],
        button: [{type: "submit", label: "查询", method: "query", icon: 'query'}, {type: "reset", label: "重置"}],
        methods: {
            query: function query(data) {
                queryTable.reload(setStatus());
            }
        }
    });
    var mergeForm = $("#mergeForm").adpForm({
        layout: 'vertical',
        elem: [
            {type: "text", label: "料框编号", name: "containerId", verify: "required", placeholder: "请输入内容"},
            {
                type: "select", label: "料框状态", name: "status", placeholder: "请选择状态",
                data: [{key: "初始空闲", value: "初始空闲"}, {key: "空框待用", value: "空框待用"}, {key: "待入库", value: "待入库"},
                    {key: "在库", value: "在库"}, {key: "待返工", value: "待返工"}, {key: "待出库", value: "待出库"},
                    {key: "待退料", value: "待退料"}, {key: "已出库", value: "已出库"}]
            },
            {type: "text", label: "详情", name: "details", placeholder: "请输入内容"},
            {type: "hidden", name: "id"}
        ],
        button: [
            {type: "submit", label: "保存", method: "submit"},
            {type: "reset", label: "重置"}
        ],
        methods: {
            submit: function submit(data) {
                SV("Container")("handleErrorContainer")(data);
                $("#mergeFormDiv").close();
                queryTable.reload(setStatus());
            }
        }

    });

    var queryTable = $("#queryTable").adpTable({
        url: '../rs/Container/list',
        where: setStatus(),
        cols: [[
            {field: 'id', title: 'ID', type: 'checkbox', width: 30, sort: true, fixed: 'left'},
            {field: 'containerId', title: '料框编号', width: 180},
            {field: 'status', title: '料框状态', width: 180},
            {fixed: 'right', title: '操作', width: 200, align: 'center', toolbar: '#OPERATION_ROW_TPL'}
        ]],
        methods: {
            edit: function edit(data, tr) {
                $("#mergeFormDiv").open("编辑料框");
                mergeForm.reset();
                mergeForm.data(data);
            },
        }
    });

    function setStatus() {
        var para = queryform.data();
        para.isError = true;
        return para;
    }
</script>